package sudoku.ui;


import javax.swing.JDialog;
import javax.swing.JOptionPane;

import sudoku.controller.Controller;
import sudoku.util.Language;


/**
 * @author Romet
 *
 */
public class WinUI {

	private volatile SudokuUI m2ng;
	private volatile Language language;
	private volatile Controller controller;
	
	/**
	 * Seadistab võiduakna ja joonistab selle.
	 * @param m2ng põhiakna graafika klassi isend
	 */
	public WinUI(Language language, SudokuUI m2ng, Controller controller){
		this.language = language;
		this.m2ng = m2ng;
		this.controller = controller;
		JOptionPane pane = new JOptionPane(this.language.getWin_message());
		pane.setOptions(new Object[] {language.getButton_yes(), language.getButton_no()});
		JDialog dialog = pane.createDialog(this.m2ng, language.getWin_title());
		dialog.setVisible(true);
		Object selectedValue = pane.getValue();
		if (selectedValue != null && !selectedValue.equals(language.getButton_no())){
			this.controller.handleEvent(Controller.UUS_M2NG_EVENT);
		}
		else {			
		}
	}
}
